home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_d / isamexpt.zip / WNTISAM1.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-05  |  14KB  |  485 lines

  1. {HISTORY of Changes:
  2.   18.01.1996 Property NAME of ISAMBROWSER changed form ISAMBROWSER1 to RECORDNAME+BROWSER1
  3.   }
  4. unit Wntisam1;
  5.  
  6. interface
  7. Uses Classes, Forms, Graphics;
  8.  
  9. Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
  10.                              IniDatNam,IniBrwNam: String;
  11.                              Fnt: TFont;
  12.                              IIDList,KeyList,RecList: TStringList;
  13.                              DBase_Export,DBase_Import: Boolean;
  14.                              Sprache: Integer;
  15.                              TblCreateBttn, SetupBttnCheck: Boolean): TForm;
  16.  
  17. implementation
  18.  
  19. Uses UToolDll, WinTypes, WinProcs, SysUtils,
  20.      ExtCtrls, Buttons, Controls, IsamTabl, IsamNav, IsamBrow,
  21.      Proxies, IStreams, FvcBrows;
  22.  
  23. Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
  24.                              IniDatNam,IniBrwNam: String;
  25.                              Fnt: TFont;
  26.                              IIDList,KeyList,RecList: TStringList;
  27.                              DBase_Export,DBase_Import: Boolean;
  28.                              Sprache: Integer;
  29.                              TblCreateBttn, SetupBttnCheck: Boolean): TForm;
  30. var
  31.   BtnPos         : TPoint;
  32.   EdMethod,Method: TMethod;
  33.   MP,UP,Up1,Up2,Up3: TPanel;
  34.   SP             : TSpeedButton;
  35.   Tbl            : TIsamTable;
  36.   Tm             : TTimer;
  37.   i,k            : Integer;
  38.   ND             : TIsamNavigator;
  39.   Grd            : TIsamBrowser;
  40.   Hdr            : THeader;
  41.   x              : Integer;
  42.   RStr,NStr,xStr,RNam : String;
  43.   Liste1,Liste2,Liste3: TStringList;
  44. begin
  45.   Result := TProxyForm.CreateAs('T' + FormIdent);
  46.   with Result do begin
  47.     BorderStyle := bsDialog;
  48.     AutoScroll  := True;
  49.     Left  := 92;
  50.     Top   := 97;
  51.     Width := 562;
  52.     Height:= 352;
  53.     Position := poScreenCenter;
  54.     Name := FormIdent;
  55.     Caption := 'Browser';
  56.     Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
  57.     Method.Data := Result;
  58.     OnCreate    := TNotifyEvent(Method);
  59.     Method.Code := TProxyForm(Result).CreateMethod('FormDestroy');
  60.     Method.Data := Result;
  61.     OnDestroy   := TNotifyEvent(Method);
  62.     Method.Code := TProxyForm(Result).CreateMethod('FormShow');
  63.     Method.Data := Result;
  64.     OnShow      := TNotifyEvent(Method);
  65.     with Font do begin
  66.       Color := clBlack;
  67.       Height:= -11;
  68.       Name := 'Arial';
  69.       Size := 8;
  70.       Style:= [fsBold];
  71.     end;
  72.  
  73.     MP:= TPanel.Create(Result);
  74.     with MP do begin
  75.       Parent := Result;
  76.       Name   := 'Panel1';
  77.       Left   := 0;
  78.       Top    := 0;
  79.       Width  := 554;
  80.       Height := 41;
  81.       Align  := alTop;
  82.       ParentShowHint:= False;
  83.       ShowHint := True;
  84.       TabOrder := 1;
  85.       Caption:= '';
  86.     end;
  87.  
  88.     Tm:= TTimer.Create(Result);
  89.     With Tm do begin
  90.       Interval:= 1000;
  91.       Name:= FormIdent+'Timer';
  92.       Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
  93.       Method.Data := Result;
  94.       Tm.OnTimer := TNotifyEvent(Method);
  95.     end;
  96.  
  97.     Hdr:= THeader.Create(Result);
  98.     with Hdr do begin
  99.       Parent:= Result;
  100.       Name:= 'HEADER1';
  101.       Left:= 0;
  102.       Top:= 41;
  103.       Height:= 25;
  104.       Width:= 554;
  105.       Method.Code := TProxyForm(Result).CreateMethod('Header1Sized');
  106.       Method.Data := Result;
  107.       OnSized:= TSectionEvent(Method);
  108.     end;
  109.  
  110.     Tbl:= TIsamTable.Create(Result);
  111.     with Tbl do begin
  112.       Name:= FormIdent+'TABLE';
  113.       TableName:= TblName;
  114.       BrowserName:= 'IsamBrowser1';
  115.       HeaderName:= 'HEADER1';
  116.       Ansiconvert:= True;
  117.       Liste1:= TStringList.Create;
  118.       {IIDProc.Clear;}
  119.       x:= 0;
  120.       While x < IIDList.Count do begin
  121.         Liste1.Add(IIDList[x]);
  122.         Inc(x);
  123.       end;
  124.       MaxKeys:= x;
  125.       IIDProc:= Liste1;
  126.       Liste1.Free;
  127.       Liste2:= TStringList.Create;
  128.       {IsamRecord.Clear;}
  129.       RecordName:= '';
  130.       x:= 0;
  131.       While x < RecList.Count do begin
  132.         Liste2.Add(RecList[x]);
  133.         RStr:= Uppercase(RecList[x]);
  134.         Strip(RStr);
  135.         if Pos('=RECORD',RStr) > 0 then RecordName:= Copy(RStr,1,Pos('=RECORD',RStr)-1);
  136.         inc(x);
  137.       end;
  138.       RNam:= RecordName;
  139.       IsamRecord:= Liste2;
  140.       Liste2.Free;
  141.       {IsamKeyProc.Clear;}
  142.       Liste3:= TStringList.Create;
  143.       K:= 0;
  144.       if KeyList.Count > 0 then begin
  145.         Liste3.Add('Function '+RNam+'KeyProc(Var Daten; KeyNr:Word): IsamKeyStr;');
  146.         Liste3.Add('var s : String;');
  147.         Liste3.Add('begin');
  148.         Liste3.Add('  s:= '+Chr(39)+Chr(39)+';');
  149.         Liste3.Add('  With '+RNam+'(Daten) do begin');
  150.         Liste3.Add('    case KeyNr of');
  151.         For x:= 0 to KeyList.Count-1 do begin
  152.           NStr:= KeyList[x];
  153.           NStr:= UpperCase(NStr);
  154.           if Pos(';',NStr) = 0 then KeyList[x]:= KeyList[x]+';';
  155.           Strip(NStr);
  156.           if (Pos('KEYBEGIN',NStr) = 0) and (Pos('KEYEND',NStr) = 0) then begin
  157.             inc(K);
  158.             Str(k,xStr);
  159.             Liste3.Add(xStr+': '+KeyList[x]);
  160.           end;
  161.         end;
  162.         Liste3.Add('    end;');
  163.         Liste3.Add('  end;');
  164.         Liste3.Add('  '+RNam+'KEYPROC:= S;');
  165.         Liste3.Add('end;');
  166.       end;
  167.       IsamKeyProc:= Liste3;
  168.       Liste3.Free;
  169.       MyUnitName:= FormIdent;
  170.     end;
  171.  
  172.     Grd:= TIsamBrowser.Create(Result);
  173.     with Grd do begin
  174.       Parent          := Result;
  175.       Name            := RNam+'Browser1';
  176.       Left            := 0;
  177.       Top             := 66;
  178.       Width           := 554;
  179.       Height          := 232;
  180.       Align           := alNone;
  181.       JustRightChar   := '░';
  182.       JustLeftChar    := '|';
  183.       JustCenterChar  := '~';
  184.       Color           := clSilver;
  185.       BrowserHeader   := Hdr;
  186.       Table           := Tbl;
  187.       Font.Color      := Fnt.Color;
  188.       Font.Height     := Fnt.Height;
  189.       Font.Name       := Fnt.Name;
  190.       Font.Style      := Fnt.Style;
  191.       ParentFont      := False;
  192.       TabOrder        := 2;
  193.       EdMethod.Code := TProxyForm(Result).CreateMethod('EditBttnClick');
  194.       EdMethod.Data := Result;
  195.       Grd.OnDblClick  := TNotifyEvent(EdMethod);
  196.       Method.Code:= TProxyForm(Result).CreateMethod(RNam+'Browser1BuildRow');
  197.       Method.Data:= Result;
  198.       Grd.OnBuildRow:= TBuildRowEvent(Method);
  199.     end;
  200.  
  201.     ND:= TIsamNavigator.Create(Result);
  202.     with ND do begin
  203.       Parent:= MP;
  204.       Browser:= Grd;
  205.       Name:= 'IsamNavigator1';
  206.       ConfirmDelete:= False;
  207.       Left:= 8;
  208.       Top:= 8;
  209.       VisibleButtons:= [nbFirst,nbPrior,nbNext,nbLast];
  210.       Width:= 100;
  211.     end;
  212.  
  213.     Sp:= TSpeedButton.Create(Result);
  214.     with SP do begin
  215.       Parent:= MP;
  216.       Left:= 128;
  217.       Top := 8;
  218.       Width := 25;
  219.       Height := 25;
  220.       if Sprache = 1 then Hint:= 'New record'
  221.       else Hint := 'Neuer Datensatz';
  222.       Name := 'NeuBttn';
  223.       Glyph.Handle:= LoadBitmap(HInstance,'IS_NEU');
  224.       Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
  225.       Method.Data := Result;
  226.       Sp.OnClick := TNotifyEvent(Method);
  227.     end;
  228.  
  229.     Sp:= TSpeedButton.Create(Result);
  230.     with SP do begin
  231.       Parent:= MP;
  232.       Left:= 156;
  233.       Top := 8;
  234.       Width := 25;
  235.       Height := 25;
  236.       if Sprache = 1 then Hint:= 'Edit record'
  237.       else Hint := 'Datensatz bearbeiten';
  238.       Name := 'EditBttn';
  239.       Glyph.Handle:= LoadBitmap(HInstance,'IS_AENDERN');
  240.       Sp.OnClick := TNotifyEvent(EdMethod);
  241.     end;
  242.  
  243.     Sp:= TSpeedButton.Create(Result);
  244.     with SP do begin
  245.       Parent:= MP;
  246.       Left:= 184;
  247.       Top := 8;
  248.       Width := 25;
  249.       Height := 25;
  250.       if Sprache = 1 then Hint:= 'Search'
  251.       else Hint := 'Suchen';
  252.       Name := 'SuchBttn';
  253.       Glyph.Handle:= LoadBitmap(HInstance,'IS_SUCH');
  254.       Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
  255.       Method.Data := Result;
  256.       Sp.OnClick := TNotifyEvent(Method);
  257.     end;
  258.  
  259.     Sp:= TSpeedButton.Create(Result);
  260.     with SP do begin
  261.       Parent:= MP;
  262.       Left:= 212;
  263.       Top := 8;
  264.       Width := 25;
  265.       Height := 25;
  266.       if Sprache = 1 then Hint:= 'sort-order'
  267.       else Hint := 'Sortierordnung';
  268.       Name := 'KeyBttn';
  269.       Glyph.Handle:= LoadBitmap(HInstance,'IS_KEY');
  270.       Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
  271.       Method.Data := Result;
  272.       Sp.OnClick := TNotifyEvent(Method);
  273.     end;
  274.  
  275.     Sp:= TSpeedButton.Create(Result);
  276.     with SP do begin
  277.       Parent:= MP;
  278.       Left:= 240;
  279.       Top := 8;
  280.       Width := 25;
  281.       Height := 25;
  282.       if Sprache = 1 then Hint:= 'Delete'
  283.       else Hint := 'L÷schen';
  284.       Name := 'LoeschBttn';
  285.       Glyph.Handle:= LoadBitmap(HInstance,'IS_LOESCHEN');
  286.       Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
  287.       Method.Data := Result;
  288.       Sp.OnClick := TNotifyEvent(Method);
  289.     end;
  290.  
  291.     Sp:= TSpeedButton.Create(Result);
  292.     with SP do begin
  293.       Parent:= MP;
  294.       Left:= 268;
  295.       Top := 8;
  296.       Width := 25;
  297.       Height := 25;
  298.       if Sprache = 1 then Hint:= 'Reorganize table'
  299.       else Hint := 'Tabelle reorganisieren';
  300.       Name := 'ReorgBttn';
  301.       Glyph.Handle:= LoadBitmap(HInstance,'IS_REORG');
  302.       Method.Code := TProxyForm(Result).CreateMethod('ReorgBttnClick');
  303.       Method.Data := Result;
  304.       Sp.OnClick := TNotifyEvent(Method);
  305.     end;
  306.  
  307.     Sp:= TSpeedButton.Create(Result);
  308.     with SP do begin
  309.       Parent:= MP;
  310.       Left:= 296;
  311.       Top := 8;
  312.       Width := 25;
  313.       Height := 25;
  314.       if Sprache = 1 then Hint:= 'Setup browser'
  315.       else Hint := 'Browser einstellen';
  316.       Name := 'BrwBttn';
  317.       Glyph.Handle:= LoadBitmap(HInstance,'IS_BRWSETUP');
  318.       Method.Code := TProxyForm(Result).CreateMethod('BrwBttnClick');
  319.       Method.Data := Result;
  320.       Sp.OnClick := TNotifyEvent(Method);
  321.     end;
  322.  
  323.     if DBase_Export then begin
  324.       Sp:= TSpeedButton.Create(Result);
  325.       with SP do begin
  326.         Parent:= MP;
  327.         Left:= 324;
  328.         Top := 8;
  329.         Width := 25;
  330.         Height := 25;
  331.         Hint := 'DBase-Export';
  332.         Name := 'DBExpBttn';
  333.         Glyph.Handle:= LoadBitmap(HInstance,'IS_DBEXPORT');
  334.         NumGlyphs:= 2;
  335.         Method.Code := TProxyForm(Result).CreateMethod('DBExpBttnClick');
  336.         Method.Data := Result;
  337.         Sp.OnClick := TNotifyEvent(Method);
  338.       end;
  339.     end;
  340.  
  341.     if DBASE_Import then begin
  342.       Sp:= TSpeedButton.Create(Result);
  343.       with SP do begin
  344.         Parent:= MP;
  345.         if DBase_Export then Left:= 352 else Left:= 324;
  346.         Top := 8;
  347.         Width := 25;
  348.         Height := 25;
  349.         Hint := 'DBase-Import';
  350.         Name := 'DBImpBttn';
  351.         Glyph.Handle:= LoadBitmap(HInstance,'IS_DBIMPORT');
  352.         NumGlyphs:= 2;
  353.         Method.Code := TProxyForm(Result).CreateMethod('DBImpBttnClick');
  354.         Method.Data := Result;
  355.         Sp.OnClick := TNotifyEvent(Method);
  356.       end;
  357.     end;
  358.  
  359.     if TblCreateBttn then begin
  360.       Sp:= TSpeedButton.Create(Result);
  361.       with SP do begin
  362.         Parent:= MP;
  363.         Left:= 324;
  364.         if DBase_Export then Left:= Left + 28;
  365.         if DBase_Import then Left:= Left + 28;
  366.         Top := 8;
  367.         Width := 25;
  368.         Height := 25;
  369.         if Sprache = 1 then Hint := 'Create Table'
  370.         else Hint:= 'Tabelle erzeugen';
  371.         Name := 'CreateBttn';
  372.         Glyph.Handle:= LoadBitmap(HInstance,'IS_CREATE');
  373.         NumGlyphs:= 2;
  374.         Method.Code := TProxyForm(Result).CreateMethod('CreateBttnClick');
  375.         Method.Data := Result;
  376.         Sp.OnClick := TNotifyEvent(Method);
  377.       end;
  378.     end;
  379.  
  380.     if SetupBttnCheck then begin
  381.       Sp:= TSpeedButton.Create(Result);
  382.       with SP do begin
  383.         Parent:= MP;
  384.         Left:= 324;
  385.         if DBase_Export then Left:= Left + 28;
  386.         if DBase_Import then Left:= Left + 28;
  387.         if TblCreateBttn then Left:= Left + 28;
  388.         Top := 8;
  389.         Width := 25;
  390.         Height := 25;
  391.         Hint := 'Setup';
  392.         Name := 'SetupBttn';
  393.         NumGlyphs:= 2;
  394.         Glyph.Handle:= LoadBitmap(HInstance,'IS_DATSETUP');
  395.         Method.Code := TProxyForm(Result).CreateMethod('SetupBttnClick');
  396.         Method.Data := Result;
  397.         Sp.OnClick := TNotifyEvent(Method);
  398.       end;
  399.     end;
  400.  
  401.     Sp:= TSpeedButton.Create(Result);
  402.     with SP do begin
  403.       Parent:= MP;
  404.       Left:= 520;
  405.       Top := 8;
  406.       Width := 25;
  407.       Height := 25;
  408.       if Sprache = 1 then Hint:= 'End'
  409.       else Hint := 'Ende';
  410.       Name := 'ExitBttn';
  411.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ENDE');
  412.       Method.Code := TProxyForm(Result).CreateMethod('ExitBttnClick');
  413.       Method.Data := Result;
  414.       Sp.OnClick := TNotifyEvent(Method);
  415.     end;
  416.  
  417.     UP:= TPanel.Create(Result);
  418.     with UP do begin
  419.       Parent := Result;
  420.       Name := 'Panel2';
  421.       Align := alBottom;
  422.       BevelInner:= bvLowered;
  423.       Height:= 27;
  424.       ShowHint:= False;
  425.       Caption:= '';
  426.     end;
  427.  
  428.     UP1:= TPanel.Create(Result);
  429.     With UP1 do begin
  430.       Parent:= UP;
  431.       Left  := 308;
  432.       Top   := 2;
  433.       Width := 108;
  434.       Height:= 23;
  435.       Align := alRight;
  436.       BevelOuter := bvLowered;
  437.       Font.Color := clBlack;
  438.       Font.Height := -11;
  439.       Font.Name := 'Arial';
  440.       Font.Style := [];
  441.       Name:= 'ZeitPanel';
  442.       Caption:= '';
  443.     end;
  444.  
  445.     UP2:= TPanel.Create(Result);
  446.     With UP2 do begin
  447.       Parent:= UP;
  448.       Left  := 2;
  449.       Top   := 2;
  450.       Width := 127;
  451.       Height:= 23;
  452.       Align := alLeft;
  453.       Alignment:= taLeftJustify;
  454.       BevelOuter := bvLowered;
  455.       Font.Color := clBlack;
  456.       Font.Height := -11;
  457.       Font.Name := 'Arial';
  458.       Font.Style := [];
  459.       Name:= 'KeyPanel';
  460.       Caption:= 'Key';
  461.     end;
  462.  
  463.     UP3:= TPanel.Create(Result);
  464.     with UP3 do begin
  465.       Parent:= UP;
  466.       Left  := 2;
  467.       Top   := 2;
  468.       Width := 186;
  469.       Height:= 23;
  470.       Align := alClient;
  471.       ShowHint:= True;
  472.       BevelInner := bvLowered;
  473.       BevelOuter := bvNone;
  474.       Font.Color := clBlack;
  475.       Font.Height := -11;
  476.       Font.Name   := 'Arial';
  477.       Font.Style  := [];
  478.       Name:= 'Statusbar';
  479.       Caption:= '';
  480.     end;
  481.   end;
  482. end;
  483.  
  484. end.
  485.